/**
 * 权限管理相关类型定义
 * 减少any类型使用，提升类型安全性
 */

import { IBaseResponse, IPaginationParams, IPaginationResponse } from './common';

// 角色相关类型
export interface IRoleFormData {
  id?: string;
  name: string;
  organizationType: number;
  authorityType: string;
  note?: string;
  status?: number;
  menuIdList: string[];
  isAdd?: boolean;
}

export interface IRoleListItem {
  id: string;
  roleName: string;
  name: string;
  organizationType: number;
  authorityType: string;
  status: number;
  createTime: string;
  modifyTime: string;
  modifyUser: string;
}

export interface IRoleListParams extends IPaginationParams {
  roleName?: string;
  organizationType?: number;
  authorityType?: string;
}

export interface IRoleListResponse extends IBaseResponse<IPaginationResponse<IRoleListItem>> {}

// 组织类型相关类型
export interface IOrganizationTypeFormData {
  id?: string;
  type: string;
  authorityType: string;
  menuIdList: string[];
}

export interface IOrganizationTypeListItem {
  id: string;
  type: string;
  organizationName: string;
  authorityType: string;
  createTime: string;
  modifyTime: string;
}

export interface IOrganizationTypeListParams extends IPaginationParams {
  type?: string;
}

export interface IOrganizationTypeListResponse extends IBaseResponse<IPaginationResponse<IOrganizationTypeListItem>> {}

// 用户相关类型
export interface IUserFormData {
  id?: string;
  username: string;
  realName: string;
  email: string;
  mobile: string;
  gender: number;
  deptId: string;
  postIdList: string[];
  roleIdList: string[];
  status: number;
}

export interface IUserListItem {
  id: string;
  username: string;
  realName: string;
  email: string;
  mobile: string;
  gender: number;
  deptName: string;
  postNameList: string[];
  roleNameList: string[];
  status: number;
  createDate: string;
}

export interface IUserListParams extends IPaginationParams {
  username?: string;
  realName?: string;
  email?: string;
  mobile?: string;
  deptId?: string;
  status?: number;
}

export interface IUserListResponse extends IBaseResponse<IPaginationResponse<IUserListItem>> {}

// 客户相关类型
export interface IClientFormData {
  id?: string;
  clientName: string;
  contactPerson: string;
  contactPhone: string;
  contactEmail: string;
  address: string;
  status: number;
}

export interface IClientListItem {
  id: string;
  clientName: string;
  contactPerson: string;
  contactPhone: string;
  contactEmail: string;
  address: string;
  status: number;
  createTime: string;
  modifyTime: string;
}

export interface IClientListParams extends IPaginationParams {
  clientName?: string;
  contactPerson?: string;
  contactPhone?: string;
  status?: number;
}

export interface IClientListResponse extends IBaseResponse<IPaginationResponse<IClientListItem>> {}

// 菜单权限相关类型
export interface IMenuPermission {
  id: string;
  name: string;
  title?: string;
  path?: string;
  component?: string;
  meta?: {
    title?: string;
    icon?: string;
    hidden?: boolean;
  };
  children?: IMenuPermission[];
  disabled?: boolean;
}

export interface IMenuTreeResponse extends IBaseResponse<IMenuPermission[]> {}

// 权限检查相关类型
export interface IPermissionCheck {
  hasPermission: (permission: string) => boolean;
  hasAnyPermission: (permissions: string[]) => boolean;
  isSuperAdmin: boolean;
}

// 组织类型权限更新
export interface IOrganizationTypePermissionUpdate {
  id: string;
  authorityType: string;
  menuIdList: string[];
}

export interface IOrganizationTypePermissionUpdateResponse extends IBaseResponse<{
  success: boolean;
  message?: string;
}> {}

// 角色状态切换
export interface IRoleStatusToggle {
  id: string;
  status: number;
}

export interface IRoleStatusToggleResponse extends IBaseResponse<{
  success: boolean;
  message?: string;
}> {}

// 角色删除
export interface IRoleDelete {
  ids: string[];
}

export interface IRoleDeleteResponse extends IBaseResponse<{
  success: boolean;
  message?: string;
}> {}
